package com.project.controller;

import com.project.entity.qo.TableReserveQo;
import com.project.entity.vo.TableNumberVo;
import com.project.entity.vo.TableReserveVo;
import com.project.result.ResponseResult;
import com.project.result.ResultCode;
import com.project.service.TableReserveService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author chen
 * @date 2022/3/29
 */
@SuppressWarnings("all")
@RequestMapping("/table/reserve")
@RestController
public class TableReserveController {
    @Resource
    private TableReserveService tableReserveService;

    /**
     * 插入桌位预定信息
     * @param tableReserveQo
     * @return
     */
    @PutMapping("/insert")
    public ResponseResult<ResultCode> insertTableReserve(@RequestBody TableReserveQo tableReserveQo){
        return tableReserveService.addTableReserve(tableReserveQo);
    }

    /**
     * 获取所有桌位预定信息
     * @return
     */
    @GetMapping("/select/all")
    public ResponseResult<List<TableReserveVo>> selectTableReserve(){
        return tableReserveService.getTableReserve();
    }

    /**
     * 根据条件获取信息
     * @param tableReserveQo
     * @return
     */
    @GetMapping("/select/by")
    public ResponseResult<List<TableReserveVo>> selectByTableReserve(@RequestBody TableReserveQo tableReserveQo){
        return tableReserveService.getByTableReserve(tableReserveQo);
    }

    /**
     * 根据id修改预约信息
     * @param tableReserveQo
     * @return
     */
    @PostMapping("/update/by/id")
    public ResponseResult<ResultCode> updateTableReserve(@RequestBody TableReserveQo tableReserveQo){
        return tableReserveService.updateTableReserve(tableReserveQo);
    }

    /**
     * 根据id修改订单状态
     * @param status 要修改的状态(0代表已处理,1代表未处理,2代表已取消)
     * @param reserveId 要修改的预约信息id
     * @return
     */
    @PostMapping("/update/status")
    public ResponseResult<ResultCode> updateStatus(Integer status,Long reserveId){
        return tableReserveService.updateStatus(status,reserveId);
    }

    /**
     * 删除
     * @param reserveId 要删除的预约信息id
     * @return
     */
    @PostMapping("/del")
    public ResponseResult<ResultCode> delTableReserve(Long reserveId){
        return tableReserveService.delTableReserve(reserveId);
    }

    /**
     * 查看预约的桌位信息
     * @param reserveId
     * @return
     */
    @GetMapping("select/table/number/by/reserve/id")
    public ResponseResult<TableNumberVo> selectTableNumberByReserveId(Long reserveId){
        return tableReserveService.selectTableNumberByReserveId(reserveId);
    }

    /**
     * 分页查询
     * @param current
     * @return
     */
    @GetMapping("/select/table/reserve/page")
    public ResponseResult<List<TableReserveVo>> selectTableReservePage(Integer current){
        return tableReserveService.selectTableReservePage(current);
    }
}



